﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.Modeling.Diagrams;

namespace UofCASE.AgileProductLinerDSL {
    //Bounding
    partial class TestPortShape {

        public override BoundsRules BoundsRules {
            get {
                return new TestPortBoundsRules();
            }
        }

        public override bool HasConnectionPoints {
            get {
                return true;
            }
        }

        public override void EnsureConnectionPoints(LinkShape link) {
            this.ConnectionPoints.Clear();
            this.CreateConnectionPoint(new PointD(AbsoluteBoundingBox.Center.X,AbsoluteBoundingBox.Bottom));
        }
    }

    public class TestPortBoundsRules : BoundsRules {

        public override RectangleD GetCompliantBounds(ShapeElement shape, RectangleD proposedBounds) {

            FeatureShape parentShape = shape.ParentShape as FeatureShape;
            if (parentShape == null) return proposedBounds;

            double x = parentShape.Size.Width / 2;
            double y = parentShape.Size.Height - (proposedBounds.Height / 2);
            return new RectangleD(x, y, proposedBounds.Width, proposedBounds.Height);

        }
    }
}
